
#include <stdio.h>
#include <math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_fft_real.h>
#include <gsl/gsl_fft_halfcomplex.h>

#pragma comment(lib, "libgsl.a")  
#pragma comment(lib, "libgslcblas.a")  

int
main(void)
{
	int i;
	const int n = 100;
	//   double data[n];
	double data[100];

	gsl_fft_real_wavetable * real;
	gsl_fft_halfcomplex_wavetable * hc;
	gsl_fft_real_workspace * work;

	for (i = 0; i < n; i++)
	{
		data[i] = 0.0;
	}

	for (i = n / 3; i < 2 * n / 3; i++)
	{
		data[i] = 1.0;
	}

	for (i = 0; i < n; i++)
	{
		printf("%d: %e\n", i, data[i]);
	}
	printf("\n");

	work = gsl_fft_real_workspace_alloc(n);
	real = gsl_fft_real_wavetable_alloc(n);

	gsl_fft_real_transform(data, 1, n,
		real, work);

	gsl_fft_real_wavetable_free(real);

	for (i = 11; i < n; i++)
	{
		data[i] = 0;
	}

	hc = gsl_fft_halfcomplex_wavetable_alloc(n);

	gsl_fft_halfcomplex_inverse(data, 1, n,
		hc, work);
	gsl_fft_halfcomplex_wavetable_free(hc);

	for (i = 0; i < n; i++)
	{
		printf("%d: %e\n", i, data[i]);
	}

	gsl_fft_real_workspace_free(work);
	return 0;
}